package com.sykj.seaflow.warm.core.config;

import com.sykj.seaflow.warm.core.expression.*;
import com.sykj.seaflow.warm.core.replace.WarmTaskServiceImpl;
import com.sykj.seaflow.warm.ext.dao.SeaFlowHisTaskDaoImpl;
import org.dromara.warm.flow.core.dao.FlowHisTaskDao;
import org.dromara.warm.flow.core.invoker.FrameInvoker;
import org.dromara.warm.flow.core.service.HisTaskService;
import org.dromara.warm.flow.core.service.impl.HisTaskServiceImpl;
import org.dromara.warm.flow.core.utils.ExpressionUtil;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;

import java.util.function.Consumer;
import java.util.function.Supplier;

@Configuration
public class WarmFlowConfig implements InitializingBean {

    @Bean
    @Primary
    public FlowHisTaskDao flowHisTaskDao() {
        return new SeaFlowHisTaskDaoImpl();
    }

    /**
     * 自定义填充 （可配置文件注入，也可用@Bean/@Component方式）
     */
//    @Bean
//    public DataFillHandler dataFillHandler() {
//        return new CustomDataFillHandler();
//    }

    /**
     * mybatis plus 注入了
     * 全局租户处理器（可配置文件注入，也可用@Bean/@Component方式）
     */
//    @Bean
//    public TenantHandler tenantHandler() {
//        return new CustomTenantHandler();
//    }


    @Override
    public void afterPropertiesSet() throws Exception {
        ExpressionStrategySimpleAnd expressionStrategySimpleAnd = new ExpressionStrategySimpleAnd();
        ExpressionStrategySimpleOr expressionStrategySimpleOr = new ExpressionStrategySimpleOr();
        ExpressionStrategyDefault expressionStrategyDefault = new ExpressionStrategyDefault();
        ExpressionStrategyReject expressionStrategyReject = new ExpressionStrategyReject();
        ExpressionStrategyPass expressionStrategyPass = new ExpressionStrategyPass();
        ExpressionUtil.setExpression(expressionStrategySimpleAnd);
        ExpressionUtil.setExpression(expressionStrategySimpleOr);
        ExpressionUtil.setExpression(expressionStrategyDefault);
        ExpressionUtil.setExpression(expressionStrategyReject);
        ExpressionUtil.setExpression(expressionStrategyPass);
    }
}
